package com.accenture.fd.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.accenture.fd.entity.User;

@Mapper
public interface AnotationUserDao {

	     @Select("SELECT id,user_name,password,email FROM t_user where id = #{userid}")
	     @Results({
	             @Result(property = "userid", column = "id"),
	             @Result(property = "username", column = "user_name"),
	             @Result(property = "password", column = "password"),
	             @Result(property = "email", column = "email"),
	     })
	     User findById(@Param("userid") String userid);

	     @Insert("insert into t_user value (#{user.userid},null,#{user.password},null,null)")
	     void save(@Param("user")User user);
	     
	     @Insert({
	    	 "<script>",
	    	 "insert into t_user value ",
	    	 "<foreach collection='userList' item='user' index='index' separator=','>",
	    	 "(#{user.userid},null,#{user.password},null,null)",
	    	 "</foreach>",
	    	 "</script>"
	    	})
	     void saveAll(@Param(value="userList") List<User> userList);
}